<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: replaceImages.js</title>
    
    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">
    
    <h1 class="page-title">Source: replaceImages.js</h1>
    
    


    
    <section>
        <article>
            <pre class="prettyprint source"><code>/**
 * Get the height of an HTML image
 * @method getImageHeight
 * @param {Image} image
 */
function getImageHeight(image) {
  return image.height;
}

/**
 * Get the width of an HTML image
 * @method getImageWidth
 * @param {Image} image
 */
function getImageWidth(image) {
  return image.width;
}

/**
 * Replace replace the `src` attribute of a list of images with images of the same width and height
 * from placekitten or placepuppy, depending on location.
 * @method replaceImages
 * @param {Images[]} images A list of HTML Images to be replaced. The list can be an Array or
 * NodeList.
 * @param {string} location A location string used to determine what kind of image to show.
 */
function replaceImages(images, location) {
  var baseImageUrl, height, width, image;
  switch (location) {
  case 'Memphis':
    // Use puppies for Memphis
    baseImageUrl = 'http://placepuppy.it/';
    break;
  default:
    // use kittens everywhere else
    baseImageUrl = 'http://placekitten.com/g/';
    break;
  }
  for (var i=0,len=images.length; i&lt;len; i++) {
    image = images[i];
    height = getImageHeight(image);
    width = getImageWidth(image);
    image.src = baseImageUrl + width + '/' + height;
  }
}
</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Global</h3><ul><li><a href="global.html#getAreaCodes">getAreaCodes</a></li><li><a href="global.html#getImageHeight">getImageHeight</a></li><li><a href="global.html#getImages">getImages</a></li><li><a href="global.html#getImageWidth">getImageWidth</a></li><li><a href="global.html#getLocation">getLocation</a></li><li><a href="global.html#getPhoneNumber">getPhoneNumber</a></li><li><a href="global.html#getUserName">getUserName</a></li><li><a href="global.html#main">main</a></li><li><a href="global.html#replaceImages">replaceImages</a></li><li><a href="global.html#validatePhoneNumber">validatePhoneNumber</a></li></ul>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Mon Sep 08 2014 09:08:13 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
